package com.example.apprendrechinois.avis;

import com.example.apprendrechinois.MainActivity;
import com.example.apprendrechinois.R;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class Avis extends Activity {
	private Button ButtonEnvoi, ButtonRetour;
    private TextView text; 
    private EditText textClient;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_avis);
        
        
        text = (TextView) findViewById(R.id.Avis1);
        text.setTypeface(Typeface.defaultFromStyle(Typeface.ITALIC), Typeface.ITALIC);       
        
        textClient = (EditText) findViewById(R.id.Avis2);
        ButtonEnvoi = (Button) findViewById(R.id.buttonEnvoi);
        ButtonEnvoi.setTypeface(Typeface.defaultFromStyle(Typeface.ITALIC), Typeface.ITALIC);    
        ButtonRetour = (Button) findViewById(R.id.buttonRetour);
        ButtonRetour.setTypeface(Typeface.defaultFromStyle(Typeface.ITALIC), Typeface.ITALIC);    
        
        ButtonEnvoi.setOnClickListener(new OnClickListener(){

			public void onClick(View v) {
				// TODO Auto-generated method stub
				final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
				emailIntent.setType("plain/text");
				emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"chongchong.lou@gmail.com"});
				emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "CHINOIS FACILE -- MESSAGE RETOUR DU CLIENT");
				emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, textClient.getText().toString());
				try {
				    startActivity(Intent.createChooser(emailIntent, "Envoi mail..."));
				} catch (android.content.ActivityNotFoundException ex) {
					ex.printStackTrace();
				}
				/*
				Intent intentMain = new Intent();
				intentMain.setClass(Avis.this, MainActivity.class);
				startActivity(intentMain);
				Avis.this.finish();
				*/
			}
          });
        
        ButtonRetour.setOnClickListener(new OnClickListener(){

			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intentMain = new Intent();
				intentMain.setClass(Avis.this, MainActivity.class);
				startActivity(intentMain);
				Avis.this.finish();
			}
          });
    }
}	
